package com.zp.collection;

import java.util.HashSet;

public class HashSetTest {
	public static void main(String[] args) {
		
		HashSet<People> set = new HashSet<People>();
		HashSet<String> hashSet = new HashSet<String>();
		set.add(new People("zhangpeng"));
		set.add(new People("lisi"));
		set.add(new People("zhangpeng"));
		
		People p = new People("zhangsan");
		
		set.add(p);
		set.add(p);
		
		String str1 = new String("aaa");
		String str2 = new String("aaa");
		
		hashSet.add(str1);
		hashSet.add(str2);
		
		System.out.println(str1.hashCode() == str2.hashCode());
		System.out.println(hashSet);
		//结果：[aaa]
		
		System.out.println(set);
		//结果1：[com.zp.collection.People@1fb8ee3, com.zp.collection.People@c17164, com.zp.collection.People@61de33]
		//结果2：[com.zp.collection.People@c17164]
	}
}
